package com.javakc.pms.orderManagement.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.javakc.pms.instruction.entity.Instruction;
import com.javakc.pms.orderManagement.entiy.OrderManagement;
import com.javakc.pms.orderManagement.mapper.OrderManagementMapper;
import com.javakc.pms.orderManagement.service.OrderManagementService;
import com.javakc.servicebase.config.InstructionQuery;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

import java.util.List;

@Service
public class OrderManagementServiceImpl extends ServiceImpl<OrderManagementMapper, OrderManagement> implements OrderManagementService {



    @Override
    public void findPageOrderManagement(Page<OrderManagement> orderManagementPage, InstructionQuery instructionQuery) {
        QueryWrapper<OrderManagement> queryWrapper = new QueryWrapper<>();
        if(!ObjectUtils.isEmpty(instructionQuery)){
            if(!ObjectUtils.isEmpty(instructionQuery.getNumbering())){
                queryWrapper.like("numbering",instructionQuery.getNumbering());
            }
            if (!ObjectUtils.isEmpty(instructionQuery.getBeginDate())) {
                queryWrapper.ge("gmt_create", instructionQuery.getBeginDate());
            }
            if (!ObjectUtils.isEmpty(instructionQuery.getEndDate())) {
                queryWrapper.lt("gmt_create", instructionQuery.getEndDate());
            }
        }
        queryWrapper.orderByDesc("gmt_create");
        baseMapper.selectPage(orderManagementPage,queryWrapper);
    }

//    @Override
//    public boolean save(OrderManagement orderManagement) {
//        return baseMapper.save(orderManagement);
//    }


    @Override
    public List<OrderManagement> select() {
       return baseMapper.select();
    }

    @Override
    public OrderManagement selectById(int id) {
        return baseMapper.selectById(id);
    }


    @Override
    public List<OrderManagement> selectPage(int pageNo, int pageSize) {
        return baseMapper.selectPage(pageNo,pageSize);
    }

//    @Override
//    public List<OrderManagement> selectPage(int pageNo, int pageSize) {
//        return baseMapper.selectPage(pageNo,pageSize);
//    }


}
